package com.ymttest.database.sqlwapper.hunter;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.ymt.database.SqlManager;
import com.ymttest.database.model.hunter.ManageServiceFeeConfig;

public class ManageServiceFeeConfigWrapper {
	
	SqlManager manager;

	public ManageServiceFeeConfigWrapper() {
		manager = new SqlManager("tradingsettlement");
	}

	@SuppressWarnings("unchecked")
	public ManageServiceFeeConfig selectByPrimaryKey(Long id) {
    	
		ManageServiceFeeConfig manageServiceFeeConfig = new ManageServiceFeeConfig();
    	List<ManageServiceFeeConfig> result = manager
                .getSelectResults(
                        "com.ymttest.database.mapping.hunter.ManageServiceFeeConfigMapper.selectByPrimaryKey",
                        id);
        manager.commit();
        
		if (result.size() > 0) {
			manageServiceFeeConfig = result.get(0);
		}
		
        return manageServiceFeeConfig;
    }
    
	// 通过费用类型、当前和父hunter等级获取费用信息
	@SuppressWarnings({ "unchecked", "rawtypes" })
	public ManageServiceFeeConfig selectConfigByTypeAndHunterLevel(
			int serviceFeeType, int productType, int currencyHunterLevel, int parentHunterLevel) {

		ManageServiceFeeConfig manageServiceFeeConfig = new ManageServiceFeeConfig();

		Map m = new HashMap<String, String>();

		m.put("service_fee_type", serviceFeeType);
		m.put("currency_hunter_level", currencyHunterLevel);
		m.put("parent_hunter_level", parentHunterLevel);
		m.put("product_type", productType);

		List<ManageServiceFeeConfig> result = manager
				.getSelectResults(
						"com.ymttest.database.mapping.hunter.ManageServiceFeeConfigMapper.selectConfigByTypeAndHunterLevel",
						m);
		manager.commit();

		if (result.size() > 0) {
			manageServiceFeeConfig = result.get(0);
		}

		return manageServiceFeeConfig;
	}
	
	// 获取大礼包特殊的商品配置
	@SuppressWarnings({ "unchecked", "rawtypes" })
	public ManageServiceFeeConfig selectConfigBySpecialType(
			int serviceFeeType, int specialType, int currencyHunterLevel,
			int parentHunterLevel) {

		ManageServiceFeeConfig manageServiceFeeConfig = new ManageServiceFeeConfig();

		Map m = new HashMap<String, String>();

		m.put("service_fee_type", serviceFeeType);
		m.put("currency_hunter_level", currencyHunterLevel);
		m.put("parent_hunter_level", parentHunterLevel);
		m.put("special_type", specialType);

		List<ManageServiceFeeConfig> result = manager
				.getSelectResults(
						"com.ymttest.database.mapping.hunter.ManageServiceFeeConfigMapper.selectConfigBySpecialType",
						m);
		manager.commit();

		if (result.size() > 0) {
			manageServiceFeeConfig = result.get(0);
		}

		return manageServiceFeeConfig;
	}
	
	public static void main(String[] args) {
		
		ManageServiceFeeConfigWrapper wrapper = new ManageServiceFeeConfigWrapper();
		
		System.out.println(wrapper.selectConfigBySpecialType(1, 0, 1, 3).getService_fee_amount());
	}
}
